<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>统一地图平台</title><link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <style>
        html,
        body,
        #mapui {
            width: 100%;
            height: 100%;
        }

        html,
        body {
            margin: 0;
            padding: 0;
        }
    </style>
</head>

<body>
    <div id="mapui"></div>

    <script src="./js_example/script/map.min.js"></script>
    <script src="./js_example/script/demo.js"></script>

    <script>
        var amap = null;
        map.Factory.create('mapui', {
            style: style,
            center: center, // 中心点
            zoom: 17, // 当前地图级别
            maxZoom: 19, // 地图最大级别
            minZoom: 1, // 地图最小级别
            strategy: ['mapboxgl', 'openlayers', 'leaflet'],
            fullExtent: {
                xmin: 108.23365,
                ymin: 17.95253,
                xmax: 111.78395,
                ymax: 20.13104
            }
        }, (o) => {
            amap = o;
            let center = amap.getCenter();
            var jsonData = {
                "type": "FeatureCollection",
                "features": [{
                    "type": "Feature",
                    "geometry": {
                        "type": "Polygon",
                        "coordinates": [
                            [
                                center,
                                [center[0], center[1] + 0.0006],
                                [center[0] - 0.0006, center[1] + 0.0006],
                                [center[0] - 0.0006, center[1]],
                                [center[0], center[1]]
                            ]
                        ]
                    },
                    properties: {
                        color: '#FFFFFF',
                        height: 50,
                        name: '建筑物1',
                        baseHeight: 10,
                    }
                }, {
                    "type": "Feature",
                    "geometry": {
                        "type": "Polygon",
                        "coordinates": [
                            [
                                [center[0] + 0.001, center[1] + 0.001],
                                [center[0] + 0.001, center[1] + 0.0016],
                                [center[0] + 0.0004, center[1] + 0.0016],
                                [center[0] + 0.0004, center[1] + 0.001],
                                [center[0] + 0.001, center[1] + 0.001]
                            ]
                        ]
                    },
                    properties: {
                        color: '#FFFFFF',
                        height: 40,
                        name: '建筑物2',
                        baseHeight: 10,
                    }
                }]
            };
            amap.addSource("fillSource", {
                "type": "geojson",
                "data": jsonData
            });


            let layer = amap.addLayer("filllLayer", "fillSource", {
                'type': 'fill-extrusion',
                'paint': {
                    'fill-extrusion-color': ['get', 'color'],
                    'fill-extrusion-height': {
                        'type': 'identity',
                        'property': 'height'
                    },
                    'fill-extrusion-base': {
                        'type': 'identity',
                        'property': 'baseHeight'
                    },
                    'fill-extrusion-opacity': 0.8
                },
            });
        });
    </script>
</body>

</html>